﻿using Core;
using System;
using UnityEngine;


[CreateAssetMenu(menuName = "Mini/Sys/Conf/Param")]
public class TblParam : ScriptableObject, ITable
{
    [Serializable]
    public class IntConf
    {
        public string name;
        public int value;
    }

    [Serializable]
    public class StringConf
    {
        public string name;
        public string value;
    }

    [SerializeField]
    public IntConf[] IntParams;

    [SerializeField]
    public StringConf[] StringParams;

    //public Core.Game G { get; set; }

    public string GetStringParam(string key)
    {
        if (StringParams == null || StringParams.Length == 0)
        {
            return string.Empty;
        }
        for (int i = 0; i < StringParams.Length; i++)
        {
            if (StringParams[i].name == key)
            {
                return StringParams[i].value;
            }
        }
        return string.Empty;
    }

    public int GetIntParam(string key)
    {
        if (IntParams == null || IntParams.Length == 0)
        {
            return 0;
        }
        for (int i = 0; i < IntParams.Length; i++)
        {
            if (IntParams[i].name == key)
            {
                return IntParams[i].value;
            }
        }
        return 0;
    }
}
